<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"
           prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html"
           prefix="html" %>

<%@page import="com.sql.Sql" %>
<%@page import="java.util.List" %>
<html>
    <head>
        <meta http-equiv="Content-Type"
              content="text/html; charset=UTF-8">
        <title>Struts - Musica</title>
        <style type="text/css">
            @import "/musica/musica.css";
        </style>
    </head>
    <body>
        <%
        String idTema = request.getParameter("idTema");

        if (idTema == null) {
            String msg = "Ingreso incorrecto!";
            request.getSession().setAttribute("msg", msg);
            response.sendRedirect("mensaje.jsp");
        } else {
            Object[] tema = (Object[]) Sql.getFila(
                    "SELECT idCd,tema,interprete," +
                    "compositor,duracion FROM temas  " +
                    "WHERE idTema=" + idTema);

            // considerando que pueden null
            if (tema[2] == null) {
                tema[2] = "";
            }

            if (tema[3] == null) {
                tema[3] = "";
            }
        %>
        <p>&nbsp;</p>
        <p class="titulo">Modificar Tema</p>
        <html:form action="logTema">
            <html:hidden property="accion" value="UPD" />
            <html:hidden property="idTema"
                         value="<%=idTema%>" />
            <html:hidden property="idCd"
                         value="<%=tema[0].toString()%>" />
            <p class="center">
                <table border="0">
                    <tr>
                        <td>Del CD</td>
                        <td>
                            <%
            Object cd = Sql.getCampo(
                    "SELECT titulo FROM Cds " +
                    "WHERE idCd=" + tema[0].toString());
                            %>
                            <html:text property="titulo"
                                  value="<%=cd.toString()%>"
                                  size="30" readonly="true" />
                        </td>
                    </tr>
                    <tr>
                        <td>Tema</td>
                        <td>
                            <html:text property="tema"
                                  value="<%=tema[1].toString()%>"
                                  size="30" maxlength="50" />
                        </td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                        <td>
                            <html:errors
                                property="tema" />
                        </td>
                    </tr>
                    <tr>
                        <td>Int&eacute;rprete</td>
                        <td>
                            <html:text property="interprete"
                                  value="<%=tema[2].toString()%>"
                                  size="30" maxlength="50" />
                        </td>
                    </tr>
                    <tr>
                        <td>Compositor</td>
                        <td>
                            <html:text property="compositor"
                                  value="<%=tema[3].toString()%>"
                                  size="30" maxlength="50" />
                        </td>
                    </tr>
                    <tr>
                        <td>Duraci&oacute;n</td>
                        <td>
                            <html:select property="duracion">
                                <%
            for (int i = 60; i <= 600; ++i) {%>
                                <html:option
                                   value="<%=String.valueOf(i)%>">
                                   <%=i%>
                                </html:option>
                                <%}%>
                            </html:select>
                        </td>
                    </tr>
                    <tr>
                        <td align="center" colspan="2"><br>
                            <html:submit value="Actualizar" />
                        </td>
                    </tr>
                </table>
            </p>
        </html:form>

        <p class="center">
            <a href="/musica/portada.html">Home</a>
        </p>
        <%}%>
    </body>
</html>

